home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
gsdbloo.exe
/
GS_LST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-28
|
4KB
|
172 lines
unit GS_Lst;
{-----------------------------------------------------------------------------
Printer Handler
GS_Error Copyright (c) Richard F. Griffin
27 February 1992
102 Molded Stone Pl
Warner Robins, GA 31088
-------------------------------------------------------------
This unit replaces the Printer unit for output via the write(lst).
Error checking is done and a message is printed asking for operator
intervention. Printing can be terminated by pressing the Escape key.
A flag, GS_Lst_Esc is set true if Escape is pressed, and can be used
by the program to test for that condition. The program must reset
GS_Lst_Esc to false (GS_Lst_Esc := false) before trying to print
anything else, or the write command will be ignored.
Changes:
------------------------------------------------------------------------------}
interface
{$D-}
{$I-}
uses Crt, Dos, printer, GS_Error;
var
GS_Lst_Esc : boolean;
Lst: Text;
implementation
type
s255 = string[255];
var
Inch, Fnch : char;
SecNum : boolean;
KeyNum : integer;
TheStr : s255;
function GetKey : boolean;
begin
GS_Lst_Esc := false;
if KeyPressed then begin
GetKey := true;
Inch := ReadKey;
KeyNum := ord(Inch);
Secnum := KeyNum = 0;
if Secnum then
begin
Fnch := ReadKey;
Keynum := ord(Fnch);
end
else if ord(Inch) <= 27 then Secnum := true else Secnum := false;
end
else begin
Getkey := false;
secnum := false;
end;
end;
procedure Lst_Err;
var
AsczStr : string[84];
begin
gotoxy(2,14);
AsczStr := concat (#7,'Please Check Printer! ',#13,#10,
'Use [ESC] to Exit, ',
'Any Other Key to Continue.');
ShowError(162,AsczStr);
if (ErrorKey = #27) then GS_Lst_Esc := true;
end;
procedure WriteLst;
Label Skip;
VAR
rgstr : Registers;
goodio : boolean;
i : integer;
begin
goodio := false;
i := 0;
repeat
If GS_Lst_Esc then goto Skip;
{$I-} write(Printer.Lst,TheStr); {$I+}
goodio := ioresult = 0;
if not goodio then Lst_Err
else
if GetKey then
if (Secnum) and (Keynum = 27) then
begin
GS_Lst_Esc := true;
{$I-} writeln(Printer.Lst); {$I+}
goodio := ioresult = 0;
end;
until goodio or GS_Lst_Esc;
Skip:
end;
{$F+}
function LstInOut(var F : TextRec) : integer;
var i : word;
begin
with F do
begin
i := 0;
TheStr := '';
while i < BufPos do
begin
TheStr := TheStr + BufPtr^[i];
inc(i);
end;
WriteLst;
BufPos := 0;
end;
LstInOut := 0;
end;
function LstClose(var F : TextRec) : integer;
var i : word;
begin
with F do
begin
i := 0;
TheStr := '';
while i < BufPos do
begin
TheStr := TheStr + BufPtr^[i];
inc(i);
end;
TheStr := TheStr + chr(10) + chr(13);
WriteLst;
BufPos := 0;
end;
LstClose := 0;
end;
function LstOpen(var F : TextRec) : integer;
begin
with F do
begin
Mode := fmOutPut;
InOutFunc := @LstInOut;
FlushFunc := @LstInOut;
CloseFunc := @LstClose;
BufPos := 0;
LstOpen := 0;
end;
GS_Lst_Esc := false;
end;
{$F-}
begin
with TextRec(Lst) do
begin
Handle := $FFFF;
Mode := fmClosed;
BufSize := Sizeof(Buffer);
BufPtr := @Buffer;
OpenFunc := @LstOpen;
Name[0] := #0;
Rewrite(Lst);
end;
end.